package com.yizhubao.app.presenters;

import com.yizhubao.app.base.BasePresenter;
import com.yizhubao.app.base.BaseResultBean;
import com.yizhubao.app.beans.WXLoginBean;
import com.yizhubao.app.models.IdCardValidModel;
import com.yizhubao.app.models.WXLoginModel;
import com.yizhubao.app.utils.Utils;
import com.yizhubao.app.utils.net.BaseObserver;
import com.yizhubao.app.views.IdCardVaildView;
import com.yizhubao.app.views.WXLoginView;

import java.util.Map;

import h.framework.pacy.utils.LogUtil;

/**
 * @author Pacy.
 * Date: 2021/6/9/009
 * Time: 21:17
 * Mail pengwwe457621023@qq.com
 * Info 身份认证
 */
public class IdCardVaildPresenter extends BasePresenter<IdCardVaildView> {
    private IdCardValidModel model;

    public IdCardVaildPresenter() {
        model = new IdCardValidModel();
    }

    public void validRequest(Map<String, Object> map) {
        model.validRequest(map, new BaseObserver<WXLoginBean>() {
            @Override
            public void onSuccess(BaseResultBean<WXLoginBean> t) {
                if (isViewAttached()) {
                    Utils.saveUser(t.getData());
                    getView().onSuccess(t.getData());
                }
            }

            @Override
            public void onError(String errMessage) {
                if (isViewAttached()) {
                    getView().showFailure(errMessage);
                }
            }

            @Override
            public void onComplete() {
                super.onComplete();
                if (isViewAttached()) {
                    getView().showFinished();
                }

            }
        }, getView().getLifeSubject());
    }

}
